package com.servlets;

import com.pojo.PageBean;
import com.pojo.ProductType;
import com.pojo.SearchHistory;
import com.service.SearchHistoryService;
import com.service.impl.SearchHistoryServiceImpl;
import com.utils.JDBCUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;

@WebServlet("/searchHistory.do")
public class SearchHistoryServlet extends BaseServlet {
    private SearchHistoryService service = new SearchHistoryServiceImpl();

    public void pageAll(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String current = request.getParameter("current");
        String limit = request.getParameter("limit");
        Integer curr=1,lim = 10;
        if (current!=null)
            curr=Integer.parseInt(current);
        if (limit!=null)
            lim = Integer.parseInt(limit);
        PageBean<SearchHistory> page = service.findAll(lim,curr);
        response.setContentType("application/json;charset=utf-8");
        response.getWriter().write(JDBCUtil.toLayuiJson(page.getTotal(),page.getData()));
    }
}
